package com.stark.commons.spring.web.support.forest.converter;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 自定义 json 转换器。
 * <p>支持各种日期格式。
 *
 * @author Ben
 * @version 1.0.0
 * @since 2023/8/8
 */
public class ForestJacksonConverter extends com.dtflys.forest.converter.json.ForestJacksonConverter {

    private static final ObjectMapper MAPPER = new ObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false)
            .setDateFormat(new DateTimeFormat());

    @Override
    public ObjectMapper getMapper() {
        return MAPPER;
    }

}
